

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>网络协议 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/underscore.js"></script>
        <script src="../../_static/doctools.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="对象存储架构概述" href="../object-store/" />
    <link rel="prev" title="Network Encoding" href="../network-encoding/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    

















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../" class="icon icon-home"></a> &raquo;</li>
        
          <li><a href="../internals/">Ceph 内幕</a> &raquo;</li>
        
      <li>网络协议</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
          
            <a href="../../_sources/dev/network-protocol.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../">
          

          
            
            <img src="../../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/intro/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../developer_guide/">开发者指南</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../internals/">Ceph 内幕</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../blkin/">Tracing Ceph With LTTng</a></li>
<li class="toctree-l2"><a class="reference internal" href="../blkin/#tracing-ceph-with-blkin">Tracing Ceph With Blkin</a></li>
<li class="toctree-l2"><a class="reference internal" href="../bluestore/">BlueStore Internals</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cache-pool/">Cache pool</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph_krb_auth/">如何配置好 Ceph Kerberos 认证的详细文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-mirroring/">CephFS Mirroring</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-reclaim/">CephFS Reclaim Interface</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephfs-snapshots/">CephFS 快照</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx/">Cephx</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cephx_protocol/">Cephx 认证协议详细阐述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config/">配置管理系统</a></li>
<li class="toctree-l2"><a class="reference internal" href="../config-key/">config-key layout</a></li>
<li class="toctree-l2"><a class="reference internal" href="../context/">CephContext</a></li>
<li class="toctree-l2"><a class="reference internal" href="../continuous-integration/">Continuous Integration Architecture</a></li>
<li class="toctree-l2"><a class="reference internal" href="../corpus/">资料库结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cpu-profiler/">Oprofile 的安装</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cxx/">C++17 and libstdc++ ABI</a></li>
<li class="toctree-l2"><a class="reference internal" href="../deduplication/">去重</a></li>
<li class="toctree-l2"><a class="reference internal" href="../delayed-delete/">CephFS delayed deletion</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployement/">开发集群的部署</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dev_cluster_deployement/#id5">在同一机器上部署多套开发集群</a></li>
<li class="toctree-l2"><a class="reference internal" href="../development-workflow/">开发流程</a></li>
<li class="toctree-l2"><a class="reference internal" href="../documenting/">为 Ceph 写作文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../encoding/">序列化（编码、解码）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../erasure-coded-pool/">纠删码存储池</a></li>
<li class="toctree-l2"><a class="reference internal" href="../file-striping/">File striping</a></li>
<li class="toctree-l2"><a class="reference internal" href="../freebsd/">FreeBSD Implementation details</a></li>
<li class="toctree-l2"><a class="reference internal" href="../generatedocs/">Ceph 文档的构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../health-reports/">Health Reports</a></li>
<li class="toctree-l2"><a class="reference internal" href="../iana/">IANA 号</a></li>
<li class="toctree-l2"><a class="reference internal" href="../kubernetes/">Hacking on Ceph in Kubernetes with Rook</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libs/">库体系结构</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logging/">集群日志的用法</a></li>
<li class="toctree-l2"><a class="reference internal" href="../logs/">调试日志</a></li>
<li class="toctree-l2"><a class="reference internal" href="../macos/">在 MacOS 上构建</a></li>
<li class="toctree-l2"><a class="reference internal" href="../messenger/">Messenger notes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-bootstrap/">Monitor bootstrap</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-elections/">Monitor Elections</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-on-disk-formats/">ON-DISK FORMAT</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mon-osdmap-prune/">FULL OSDMAP VERSION PRUNING</a></li>
<li class="toctree-l2"><a class="reference internal" href="../msgr2/">msgr2 协议（ msgr2.0 和 msgr2.1 ）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../network-encoding/">Network Encoding</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">网络协议</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#hello">Hello</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#banner">Banner</a></li>
<li class="toctree-l4"><a class="reference internal" href="#connect">Connect</a></li>
<li class="toctree-l4"><a class="reference internal" href="#connect-reply">Connect Reply</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#msgr-protocol">MSGR Protocol</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#ceph-msgr-tag-close-0x06">CEPH_MSGR_TAG_CLOSE (0x06)</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ceph-msgr-tag-msg-0x07">CEPH_MSGR_TAG_MSG (0x07)</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ceph-msgr-tag-ack-0x08">CEPH_MSGR_TAG_ACK (0x08)</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ceph-msgr-tag-keepalive-0x09">CEPH_MSGR_TAG_KEEPALIVE (0x09)</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ceph-msgr-tag-keepalive2-0x0e">CEPH_MSGR_TAG_KEEPALIVE2 (0x0E)</a></li>
<li class="toctree-l4"><a class="reference internal" href="#ceph-msgr-tag-keepalive2-ack-0x0f">CEPH_MSGR_TAG_KEEPALIVE2_ACK (0x0F)</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../object-store/">对象存储架构概述</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd-class-path/">OSD class path issues</a></li>
<li class="toctree-l2"><a class="reference internal" href="../peering/">互联</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf/">Using perf</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_counters/">性能计数器</a></li>
<li class="toctree-l2"><a class="reference internal" href="../perf_histograms/">Perf histograms</a></li>
<li class="toctree-l2"><a class="reference internal" href="../placement-group/">PG （归置组）说明</a></li>
<li class="toctree-l2"><a class="reference internal" href="../quick_guide/">开发者指南（快速）</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rados-client-protocol/">RADOS 客户端协议</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-diff/">RBD 增量备份</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-export/">RBD Export &amp; Import</a></li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-layering/">RBD Layering</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-checklists/">Release checklists</a></li>
<li class="toctree-l2"><a class="reference internal" href="../release-process/">Ceph Release Process</a></li>
<li class="toctree-l2"><a class="reference internal" href="../seastore/">SeaStore</a></li>
<li class="toctree-l2"><a class="reference internal" href="../sepia/">Sepia 社区测试实验室</a></li>
<li class="toctree-l2"><a class="reference internal" href="../session_authentication/">Session Authentication for the Cephx Protocol</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/">测试笔记</a></li>
<li class="toctree-l2"><a class="reference internal" href="../versions/">Public OSD Version</a></li>
<li class="toctree-l2"><a class="reference internal" href="../vstart-ganesha/">NFS CephFS-RGW Developer Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../wireshark/">Wireshark Dissector</a></li>
<li class="toctree-l2"><a class="reference internal" href="../zoned-storage/">Zoned Storage Support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../osd_internals/">OSD 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../mds_internals/">MDS 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../radosgw/">RADOS 网关开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../ceph-volume/">ceph-volume 开发者文档</a></li>
<li class="toctree-l2"><a class="reference internal" href="../crimson/">Crimson developer documentation</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <div class="section" id="id1">
<h1>网络协议<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h1>
<p>This file describes the network protocol used by Ceph.  In order to understand
the way the structures are defined it is recommended to read the introduction
of <a class="reference internal" href="../network-encoding/"><span class="doc">Network Encoding</span></a> first.</p>
<div class="section" id="hello">
<h2>Hello<a class="headerlink" href="#hello" title="Permalink to this headline">¶</a></h2>
<p>The protocol starts with a handshake that confirms that both nodes are talking
ceph and shares some basic information.</p>
<div class="section" id="banner">
<h3>Banner<a class="headerlink" href="#banner" title="Permalink to this headline">¶</a></h3>
<p>第一个动作是服务器发 banner 给客户端。 banner 是由 <code class="docutils literal notranslate"><span class="pre">src/include/msgr.h</span></code> 里的 <code class="docutils literal notranslate"><span class="pre">CEPH_BANNER</span></code> 定义的。这之后是服务器端和客户端的地址，分别编码为 <code class="docutils literal notranslate"><span class="pre">entity_addr_t</span></code> 。</p>
<p>客户端会验证服务器发来的 banner 是否与自己的相匹配，若匹配，则用自己的 banner 和地址响应。</p>
</div>
<div class="section" id="connect">
<h3>Connect<a class="headerlink" href="#connect" title="Permalink to this headline">¶</a></h3>
<p>Once the banners have been verified and the addresses exchanged the connection
negotiation begins.  First the client sends a <code class="docutils literal notranslate"><span class="pre">ceph_msg_connect</span></code> structure
with its information.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">From</span> <span class="n">src</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">msgr</span><span class="o">.</span><span class="n">h</span>
<span class="n">struct</span> <span class="n">ceph_msg_connect</span> <span class="p">{</span>
        <span class="n">u64le</span> <span class="n">features</span><span class="p">;</span>            <span class="o">//</span> <span class="n">Supported</span> <span class="n">features</span> <span class="p">(</span><span class="n">CEPH_FEATURE_</span><span class="o">*</span><span class="p">)</span>
        <span class="n">u32le</span> <span class="n">host_type</span><span class="p">;</span>           <span class="o">//</span> <span class="n">CEPH_ENTITY_TYPE_</span><span class="o">*</span>
        <span class="n">u32le</span> <span class="n">global_seq</span><span class="p">;</span>          <span class="o">//</span> <span class="n">Number</span> <span class="n">of</span> <span class="n">connections</span> <span class="n">initiated</span> <span class="n">by</span> <span class="n">this</span> <span class="n">host</span><span class="o">.</span>
        <span class="n">u32le</span> <span class="n">connect_seq</span><span class="p">;</span>         <span class="o">//</span> <span class="n">Number</span> <span class="n">of</span> <span class="n">connections</span> <span class="n">initiated</span> <span class="ow">in</span> <span class="n">this</span> <span class="n">session</span><span class="o">.</span>
        <span class="n">u32le</span> <span class="n">protocol_version</span><span class="p">;</span>
        <span class="n">u32le</span> <span class="n">authorizer_protocol</span><span class="p">;</span>
        <span class="n">u32le</span> <span class="n">authorizer_len</span><span class="p">;</span>
        <span class="n">u8</span>    <span class="n">flags</span><span class="p">;</span>               <span class="o">//</span> <span class="n">CEPH_MSG_CONNECT_</span><span class="o">*</span>
        <span class="n">u8</span>    <span class="n">authorizer</span><span class="p">[</span><span class="n">authorizer_len</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="connect-reply">
<h3>Connect Reply<a class="headerlink" href="#connect-reply" title="Permalink to this headline">¶</a></h3>
<p>Once the connect has been sent the connection has effectively been opened,
however the first message the server sends must be a connect reply message.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_msg_connect_reply</span> <span class="p">{</span>
        <span class="n">u8</span>    <span class="n">tag</span><span class="p">;</span> <span class="o">//</span> <span class="n">Tag</span> <span class="n">indicating</span> <span class="n">response</span> <span class="n">code</span><span class="o">.</span>
        <span class="n">u64le</span> <span class="n">features</span><span class="p">;</span>
        <span class="n">u32le</span> <span class="n">global_seq</span><span class="p">;</span>
        <span class="n">u32le</span> <span class="n">connect_seq</span><span class="p">;</span>
        <span class="n">u32le</span> <span class="n">protocol_version</span><span class="p">;</span>
        <span class="n">u32le</span> <span class="n">authorizer_len</span><span class="p">;</span>
        <span class="n">u8</span>    <span class="n">flags</span><span class="p">;</span>
        <span class="n">u8</span>    <span class="n">authorizer</span><span class="p">[</span><span class="n">authorizer_len</span><span class="p">];</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="msgr-protocol">
<h2>MSGR Protocol<a class="headerlink" href="#msgr-protocol" title="Permalink to this headline">¶</a></h2>
<p>This is a low level protocol over which messages are delivered.  The messages
at this level consist of a tag byte, identifying the type of message, followed
by the message data.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">//</span> <span class="n">Virtual</span> <span class="n">structure</span><span class="o">.</span>
<span class="n">struct</span> <span class="p">{</span>
        <span class="n">u8</span> <span class="n">tag</span><span class="p">;</span> <span class="o">//</span> <span class="n">CEPH_MSGR_TAG_</span><span class="o">*</span>
        <span class="n">u8</span> <span class="n">data</span><span class="p">[];</span> <span class="o">//</span> <span class="n">Length</span> <span class="n">depends</span> <span class="n">on</span> <span class="n">tag</span> <span class="ow">and</span> <span class="n">data</span><span class="o">.</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The length of <code class="docutils literal notranslate"><span class="pre">data</span></code> is determined by the tag byte and depending on the
message type via information in the <code class="docutils literal notranslate"><span class="pre">data</span></code> array itself.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>There is no way to determine the length of the message if you do not
understand the type of message.</p>
</div>
<p>The message tags are defined in <code class="docutils literal notranslate"><span class="pre">src/include/msgr.h</span></code> and the current ones
are listed below along with the data they include.  Note that the defined
structures don’t exist in the source and are merely for representing the
protocol.</p>
<div class="section" id="ceph-msgr-tag-close-0x06">
<h3>CEPH_MSGR_TAG_CLOSE (0x06)<a class="headerlink" href="#ceph-msgr-tag-close-0x06" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_msgr_close</span> <span class="p">{</span>
        <span class="n">u8</span> <span class="n">tag</span> <span class="o">=</span> <span class="mh">0x06</span><span class="p">;</span>
        <span class="n">u8</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span> <span class="o">//</span> <span class="n">No</span> <span class="n">data</span><span class="o">.</span>
<span class="p">}</span>
</pre></div>
</div>
<p>The close message indicates that the connection is being closed.</p>
</div>
<div class="section" id="ceph-msgr-tag-msg-0x07">
<h3>CEPH_MSGR_TAG_MSG (0x07)<a class="headerlink" href="#ceph-msgr-tag-msg-0x07" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_msgr_msg</span> <span class="p">{</span>
        <span class="n">u8</span> <span class="n">tag</span> <span class="o">=</span> <span class="mh">0x07</span><span class="p">;</span>
        <span class="n">ceph_msg_header</span> <span class="n">header</span><span class="p">;</span>
        <span class="n">u8</span> <span class="n">front</span> <span class="p">[</span><span class="n">header</span><span class="o">.</span><span class="n">front_len</span> <span class="p">];</span>
        <span class="n">u8</span> <span class="n">middle</span><span class="p">[</span><span class="n">header</span><span class="o">.</span><span class="n">middle_len</span><span class="p">];</span>
        <span class="n">u8</span> <span class="n">data</span>  <span class="p">[</span><span class="n">header</span><span class="o">.</span><span class="n">data_len</span>  <span class="p">];</span>
        <span class="n">ceph_msg_footer</span> <span class="n">footer</span><span class="p">;</span>
<span class="p">}</span>

<span class="o">//</span> <span class="n">From</span> <span class="n">src</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">msgr</span><span class="o">.</span><span class="n">h</span>
<span class="n">struct</span> <span class="n">ceph_msg_header</span> <span class="p">{</span>
        <span class="n">u64le</span> <span class="n">seq</span><span class="p">;</span>       <span class="o">//</span> <span class="n">Sequence</span> <span class="n">number</span><span class="o">.</span>
        <span class="n">u64le</span> <span class="n">tid</span><span class="p">;</span>       <span class="o">//</span> <span class="n">Transaction</span> <span class="n">ID</span><span class="o">.</span>
        <span class="n">u16le</span> <span class="nb">type</span><span class="p">;</span>      <span class="o">//</span> <span class="n">Message</span> <span class="nb">type</span> <span class="p">(</span><span class="n">CEPH_MSG_</span><span class="o">*</span> <span class="ow">or</span> <span class="n">MSG_</span><span class="o">*</span><span class="p">)</span><span class="o">.</span>
        <span class="n">u16le</span> <span class="n">priority</span><span class="p">;</span>  <span class="o">//</span> <span class="n">Priority</span> <span class="p">(</span><span class="n">higher</span> <span class="ow">is</span> <span class="n">more</span> <span class="n">important</span><span class="p">)</span><span class="o">.</span>
        <span class="n">u16le</span> <span class="n">version</span><span class="p">;</span>   <span class="o">//</span> <span class="n">Version</span> <span class="n">of</span> <span class="n">message</span> <span class="n">encoding</span><span class="o">.</span>

        <span class="n">u32le</span> <span class="n">front_len</span><span class="p">;</span>  <span class="o">//</span> <span class="n">The</span> <span class="n">size</span> <span class="n">of</span> <span class="n">the</span> <span class="n">front</span> <span class="n">section</span><span class="o">.</span>
        <span class="n">u32le</span> <span class="n">middle_len</span><span class="p">;</span> <span class="o">//</span> <span class="n">The</span> <span class="n">size</span> <span class="n">of</span> <span class="n">the</span> <span class="n">middle</span> <span class="n">section</span><span class="o">.</span>
        <span class="n">u32le</span> <span class="n">data_len</span><span class="p">;</span>   <span class="o">//</span> <span class="n">The</span> <span class="n">size</span> <span class="n">of</span> <span class="n">the</span> <span class="n">data</span> <span class="n">section</span><span class="o">.</span>
        <span class="n">u16le</span> <span class="n">data_off</span><span class="p">;</span>   <span class="o">//</span> <span class="n">The</span> <span class="n">way</span> <span class="n">data</span> <span class="n">should</span> <span class="n">be</span> <span class="n">aligned</span> <span class="n">by</span> <span class="n">the</span> <span class="n">reciever</span><span class="o">.</span>

        <span class="n">ceph_entity_name</span> <span class="n">src</span><span class="p">;</span> <span class="o">//</span> <span class="n">Information</span> <span class="n">about</span> <span class="n">the</span> <span class="n">sender</span><span class="o">.</span>

        <span class="n">u16le</span> <span class="n">compat_version</span><span class="p">;</span> <span class="o">//</span> <span class="n">Oldest</span> <span class="n">compatible</span> <span class="n">encoding</span> <span class="n">version</span><span class="o">.</span>
        <span class="n">u16le</span> <span class="n">reserved</span><span class="p">;</span>       <span class="o">//</span> <span class="n">Unused</span><span class="o">.</span>
        <span class="n">u32le</span> <span class="n">crc</span><span class="p">;</span>            <span class="o">//</span> <span class="n">CRC</span> <span class="n">of</span> <span class="n">header</span><span class="o">.</span>
<span class="p">}</span>

<span class="o">//</span> <span class="n">From</span> <span class="n">src</span><span class="o">/</span><span class="n">include</span><span class="o">/</span><span class="n">msgr</span><span class="o">.</span><span class="n">h</span>
<span class="n">struct</span> <span class="n">ceph_msg_footer</span> <span class="p">{</span>
        <span class="n">u32le</span> <span class="n">front_crc</span><span class="p">;</span>  <span class="o">//</span> <span class="n">Checksums</span> <span class="n">of</span> <span class="n">the</span> <span class="n">various</span> <span class="n">sections</span><span class="o">.</span>
        <span class="n">u32le</span> <span class="n">middle_crc</span><span class="p">;</span> <span class="o">//</span>
        <span class="n">u32le</span> <span class="n">data_crc</span><span class="p">;</span>   <span class="o">//</span>
        <span class="n">u64le</span> <span class="n">sig</span><span class="p">;</span> <span class="o">//</span> <span class="n">Crypographic</span> <span class="n">signature</span><span class="o">.</span>
        <span class="n">u8</span>    <span class="n">flags</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>Messages are the business logic of Ceph.  They are what is used to send data and
requests between nodes.  The message header contains the length of the message
so unknown messages can be handled gracefully.</p>
<p>There are two names for the message type constants <code class="docutils literal notranslate"><span class="pre">CEPH_MSG_*</span></code> and <code class="docutils literal notranslate"><span class="pre">MSG_*</span></code>.
The only difference between the two is that the first are considered “public”
while the second is for internal use only.  There is no protocol-level
difference.</p>
</div>
<div class="section" id="ceph-msgr-tag-ack-0x08">
<h3>CEPH_MSGR_TAG_ACK (0x08)<a class="headerlink" href="#ceph-msgr-tag-ack-0x08" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_msgr_ack</span> <span class="p">{</span>
        <span class="n">u8</span>    <span class="n">tag</span> <span class="o">=</span> <span class="mh">0x08</span><span class="p">;</span>
        <span class="n">u64le</span> <span class="n">seq</span><span class="p">;</span> <span class="o">//</span> <span class="n">The</span> <span class="n">sequence</span> <span class="n">number</span> <span class="n">of</span> <span class="n">the</span> <span class="n">message</span> <span class="n">being</span> <span class="n">acknowledged</span><span class="o">.</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="ceph-msgr-tag-keepalive-0x09">
<h3>CEPH_MSGR_TAG_KEEPALIVE (0x09)<a class="headerlink" href="#ceph-msgr-tag-keepalive-0x09" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_msgr_keepalive</span> <span class="p">{</span>
        <span class="n">u8</span> <span class="n">tag</span> <span class="o">=</span> <span class="mh">0x09</span><span class="p">;</span>
        <span class="n">u8</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">];</span> <span class="o">//</span> <span class="n">No</span> <span class="n">data</span><span class="o">.</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="ceph-msgr-tag-keepalive2-0x0e">
<h3>CEPH_MSGR_TAG_KEEPALIVE2 (0x0E)<a class="headerlink" href="#ceph-msgr-tag-keepalive2-0x0e" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_msgr_keepalive2</span> <span class="p">{</span>
        <span class="n">u8</span>      <span class="n">tag</span> <span class="o">=</span> <span class="mh">0x0E</span><span class="p">;</span>
        <span class="n">utime_t</span> <span class="n">timestamp</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="ceph-msgr-tag-keepalive2-ack-0x0f">
<h3>CEPH_MSGR_TAG_KEEPALIVE2_ACK (0x0F)<a class="headerlink" href="#ceph-msgr-tag-keepalive2-ack-0x0f" title="Permalink to this headline">¶</a></h3>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">struct</span> <span class="n">ceph_msgr_keepalive2_ack</span> <span class="p">{</span>
        <span class="n">u8</span>      <span class="n">tag</span> <span class="o">=</span> <span class="mh">0x0F</span><span class="p">;</span>
        <span class="n">utime_t</span> <span class="n">timestamp</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
</div>



           </div>
           
          </div>
          <footer>
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
        <a href="../object-store/" class="btn btn-neutral float-right" title="对象存储架构概述" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
        <a href="../network-encoding/" class="btn btn-neutral float-left" title="Network Encoding" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>
        &#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).

    </p>
  </div> 

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>